package com.varian.mybatis.base;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotNull;
import lombok.Data;

/**
 * @author ben
 * @since 2024/6/23
 */
@Data
@Schema(title = "基础分页数据实体")
public class BasePage {
    @Schema(title = "当前页码", example = "1")
    @Min(value = 1, message = "当前页码不能小于1")
    @NotNull(message = "当前页码不能为空")
    private Integer current;

    @Schema(title = "每页条数", example = "10")
    @Min(value = 10, message = "每页条数不能小于10")
    @NotNull(message = "每页条数不能为空")
    private Integer size;

    public <T> Page<T> toPage() {
        return PageDTO.of(current, size);
    }
}
